#include "ds18b20.h"

void Delay1ms()		//@12.000MHz
{
	unsigned char i, j;

	i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
}


void t_convert(void)
{
	onewrite_inti();
	Delay1ms();
	write_byte(rom);
	write_byte(convert);
}

float readt(void)
{
	static unsigned char lsb = 0x00, msb = 0x00;
	int temp = 0;float t = 0.0;
	onewrite_inti();
	Delay1ms();
	write_byte(rom);
	write_byte(read_t);
	lsb = read_byte();
	msb = read_byte();
	temp = (msb << 8) | lsb;
	t = temp / 16.0;
	return t;
}
